package com.lcx.plugin.service.impl;

import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.lcx.plugin.dto.MySettingsStorageDTO;
import com.lcx.plugin.service.MySettingsStorageService;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
 * 设置储存服务实现
 *
 * @author daxiong
 * @date 2023/6/19 上午10:19
 */
@State(name = "EasyDbSetting", storages = @Storage("easy-db-setting.xml"))
public class MySettingsStorageServiceImpl implements MySettingsStorageService {

    private MySettingsStorageDTO settingsStorage = MySettingsStorageDTO.defaultVal();

    /**
     * 获取配置
     *
     * @return 配置对象
     */
    @Nullable
    @Override
    public MySettingsStorageDTO getState() {
        return settingsStorage;
    }

    /**
     * 加载配置
     *
     * @param state 配置对象
     */
    @Override
    public void loadState(@NotNull MySettingsStorageDTO state) {
        this.settingsStorage = state;
    }
}
